package view.formatters;

import model.SpeakerRole;
import tools.Translator;
import view.ResultFormatter;
import algo.DistributionResult.SingleDebateDistribution;

import com.google.inject.Inject;

public class BPSResultFormatter implements ResultFormatter {

	private final Translator tr;
	private final SpeakerRole firstGov;
	private final SpeakerRole secondGov;
	private final SpeakerRole thirdGov;
	private final SpeakerRole firstOp;
	private final SpeakerRole secondOp;
	private final SpeakerRole thirdOp;
	private final SpeakerRole fourthOp;
	private final SpeakerRole fourthGov;

	@Inject
	public BPSResultFormatter(Translator tr, SpeakerRole firstGov,
			SpeakerRole secondGov, SpeakerRole thirdGov, SpeakerRole fourthGov,
			SpeakerRole firstOp, SpeakerRole secondOp, SpeakerRole thirdOp,
			SpeakerRole fourthOp) {
		this.tr = tr;
		this.firstGov = firstGov;
		this.secondGov = secondGov;
		this.thirdGov = thirdGov;
		this.fourthGov = fourthGov;
		this.firstOp = firstOp;
		this.secondOp = secondOp;
		this.thirdOp = thirdOp;
		this.fourthOp = fourthOp;
	}

	@Override
	public String getFormattedResult(SingleDebateDistribution dist) {
		StringBuilder text = new StringBuilder();

		text.append("<table style='font-size:1.1em' border='0'><tr><th colspan=\"2\">");
		// text.append(dist.getRoom());
		text.append("Raum");
		text.append("</th></tr><tr><td><b>" + tr.tr(firstGov.getLabel())
				+ "</b><br>");
		text.append(dist.getFirstSpeakerForRole(firstGov).getName());
		text.append("</td><td><b>" + tr.tr(firstOp.getLabel()) + "</b><br>");
		text.append(dist.getFirstSpeakerForRole(firstOp).getName());
		text.append("</td></tr><tr><td><b>" + tr.tr(secondGov.getLabel())
				+ "</b><br>");
		text.append(dist.getFirstSpeakerForRole(secondGov).getName());
		text.append("</td><td><b>" + tr.tr(secondOp.getLabel()) + "</b><br>");
		text.append(dist.getFirstSpeakerForRole(secondOp).getName());
		text.append("</td></tr><tr><td><b>" + tr.tr(thirdGov.getLabel())
				+ "</b><br>");
		text.append(dist.getFirstSpeakerForRole(thirdGov).getName());
		text.append("</td><td><b>" + tr.tr(thirdOp.getLabel()) + "</b><br>");
		text.append(dist.getFirstSpeakerForRole(thirdOp).getName());
		
		text.append("</td></tr><tr><td><b>" + tr.tr(fourthGov.getLabel())
				+ "</b><br>");
		text.append(dist.getFirstSpeakerForRole(fourthGov).getName());
		text.append("</td><td><b>" + tr.tr(fourthOp.getLabel()) + "</b><br>");
		text.append(dist.getFirstSpeakerForRole(fourthOp).getName());
		text.append("</td></tr>");
		text.append("</table>");

		return text.toString();
	}

}
